<?php
error_reporting(E_ALL ^ E_NOTICE);
set_time_limit(0);
$pgsql = pg_connect("host=localhost dbname=comds  user=root  password=root")
   or die('Could not connect:'.pg_last_error());

$db_name = "comds";

$table_name = "cmds";

$connection = @mysql_connect("localhost","root","root") or die(mysql_error());

$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$logdate = pg_query($pgsql,"SELECT DISTINCT whatday FROM comds");

while ($everylogdate = pg_fetch_array($logdate)) {
  //var_dump($everylogdate);die;
    $dayActivePesonrNum_query = pg_query("SELECT count(DISTINCT deviceid)  FROM comds  where whatday ='$everylogdate[whatday]'");
    $dayActivePesonrNum = pg_fetch_array($dayActivePesonrNum_query,0);
 
   $sql = "REPLACE INTO report (dayActivePesonrNum) 
                  VALUES('$dayActivePesonrNum[0]')";
                 

$query= @mysql_query($sql,$connection) or die(mysql_error());  


}

?>
